<?php

namespace app\admin\validate\curriculum;

use app\admin\validate\Validates;

class SchoolTimetable extends Validates
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...]
     *
     * @var array
     */	
	protected $rule = [
        'ids|标识' => 'require|array',
        'id|参数' => 'require|>:0',
        'cycle|课程周期' => 'date',
        'title|标题' => 'max:30',
        'cid|主课程' => '>:0',
        'duration|时长' => 'require|>=:0',
        'start_cycle_time|课程时间开始' => 'require|date',
        'end_cycle_time|课程时间结束' => 'require|date',
        'delayed_url|录播地址' => 'url',
        'live_url|直播地址' => 'url'
    ];
    
    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'
     *
     * @var array
     */	
    protected $message = [];

    /**
     * 定义场景
     * @var []
     */
    protected $scene = [
        'index' => ['cid', 'title', 'cycle'],
        'delete' => ['id'],
        'destory' => ['ids'],
    ];

    /**
     * 定义新增场景验证
     * @return $this
     */
    public function sceneCreate()
    {
        return $this->only(['title','duration','cid','cycle','start_cycle_time','end_cycle_time','delayed_url','live_url'])
            ->append('cycle', 'require')
            ->append('title', 'require')
            ->append('cid', 'require');
    }

    /**
     * 定义新增场景验证
     * @return $this
     */
    public function sceneUpdate()
    {
        return $this->only(['title','duration','cid','cycle','start_cycle_time','end_cycle_time','delayed_url','live_url'])
            ->append('cycle', 'require')
            ->append('title', 'require')
            ->append('cid', 'require');
    }

}
